﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System.Windows;
using System.Windows.Data;

namespace FinPlusWPFControls
{
    public class FinPlusGridColFunc : FinPlusGridColBase
    {
        //construct
        public FinPlusGridColFunc(string name, bool isEnabled = false)
        {
            var tb = new FrameworkElementFactory(typeof(FinPlusValueFunction));
            tb.SetValue(FinPlusValueFunction.IsEnabledProperty, isEnabled);
            tb.SetBinding(FinPlusValueFunction.FunctiontProperty, new Binding(name) { Mode = BindingMode.OneWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
            var et = new DataTemplate() { VisualTree = tb };

            var dt = ButtonImageCell("funcButtonImage");

            Header = name;
            CellEditingTemplate = et;
            CellTemplate = dt;
            ClipboardContentBinding = new Binding(name) { Mode = BindingMode.OneWay };
            CanUserSort = true;
        }
    }
}
